﻿@model BLL.Model.Apply.ApplyInfo
@{
    Layout = null;
    ViewBag.Title = Model == null ? "新建申请" : "修改申请";
    ViewBag.OSList = ViewBag.OSList ?? new Dictionary<string, string>();
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">

    function getData() {
        return $("form").serialize();
    }

    function closeDialog() {
        $("#editDiv").data("dialog").close();
    }

    $().ready(function () {
        $(":submit").button();

        var form = $("form");

        $("#btnSave").click(function () {
            if (!form.valid()) {
                return false;
            }
            $.post("/apply/save/", getData(), function (result) {
                if (result == 'ok') {
                    alert("申请已经成功保存！");
                    closeDialog();
                }
                else {
                    alert(result);
                }
            });
            return false;
        });

        $("#btnSubmit").click(function () {
            if (!form.valid() || !confirm("提交申请后申请信息将不能更改，确定要提交该申请吗？")) {
                return false;
            }
            $.post("/apply/submit/", getData(), function (result) {
                if (result == 'ok') {
                    alert("申请已经成功提交！");
                    closeDialog();
                }
                else {
                    alert(result);
                }
            });
            return false;
        });

    });
</script>
@using (Html.BeginForm("Submit", "Apply"))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>@ViewBag.Title</legend>
        @if (Model != null)
        {
            @Html.HiddenFor(model => model.Id);
        }
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.Title)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.Title, new { @class = "search_input" })
                            <em>填写申请的主题</em>
                            <div>
                                @Html.ValidationMessageFor(model => model.Title)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.MemroySize)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.MemroySize, new { @class = "search_input" })
                            <em>需要申请的内存大小（单位：MB），只能是整数</em>
                            <div>
                                @Html.ValidationMessageFor(model => model.MemroySize)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.DiskSize)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.DiskSize, new { @class = "search_input" })
                            <em>需要申请的存储大小（单位：GB），只能是整数</em>
                            <div>
                                @Html.ValidationMessageFor(model => model.DiskSize)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.CPUCore)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextBoxFor(model => model.CPUCore, new { @class = "search_input" })
                            <em>需要申请的CPU数量（单位：个），只能是整数</em>
                            <div>
                                @Html.ValidationMessageFor(model => model.CPUCore)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            操作系统：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.DropDownListFor(model => model.OperatingSystemId, new SelectList(ViewBag.OSList, "Id", "Name"), "-选择操作系统-", new { @style = "width: 250px; margin-right:7px;" })
                            <em>如果需要预装操作系统请选择</em>
                            <div>
                                @Html.ValidationMessageFor(model => model.OperatingSystemId)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ez-wr" style="text-align: left; margin-top: 20px;">
            <div class="ez-box" style="margin: 5px;">
                <div class="ez-wr">
                    <div class="ez-fl ez-negmr ez-13" style="margin: 5px;">
                        <div class="ez-box">
                            @Html.LabelFor(model => model.Comment)：
                        </div>
                    </div>
                    <div class="ez-last ez-oh">
                        <div class="ez-box">
                            @Html.TextAreaFor(model => model.Comment, 5, 10, new { @class = "search_input", @style = "width:80%;" })
                            <div>
                                @Html.ValidationMessageFor(model => model.Comment)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <p>
            <input type="submit" value="保  存" id="btnSave" />&nbsp;&nbsp;
            <input type="submit" value="提交申请" id="btnSubmit" />
        </p>
    </fieldset>
}
